package top.itaso.app.ui.gallery;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;

import top.itaso.app.BaseFragment;
import top.itaso.app.R;
import top.itaso.app.databinding.FragmentGalleryBinding;

/**
 * @Description:
 * @Author: dengfu.su
 * @CreateDate: 2022/8/4
 */
public class GalleryFragment extends BaseFragment {

    private GalleryViewModel viewModel;
    private TextView textView;

    @Override
    protected int layoutId() {
        return R.layout.fragment_gallery;
    }

    @Override
    protected void initView(View view) {
        textView = view.findViewById(R.id.text_gallery);
    }

    @Override
    protected void initData(Context context) {
        viewModel = new ViewModelProvider(this).get(GalleryViewModel.class);
        viewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
            @Override
            public void onChanged(@Nullable String s) {
                textView.setText(s);
            }
        });
    }

}